<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* function User(name){
            this.name = name;
        }
        function Admin(name){
            User.call(this,name); // 继承User的name属性
        }
        Admin.prototype = Object.create(User.prototype);
        Admin.prototype.show = function(){}
        let admin = new Admin("张三");
        console.log(admin.name) */
        class User{
            constructor(name){
                this.name = name;
            }
            show(){
                console.log('父类方法')
            }
        }
        class Admin extends User{
            constructor(name){
                super(name); // 调用super访问父类的属性及方法
            }
        }
        
        let admin = new Admin('张三');
        console.log(admin)
        admin.show();
    </script>
</body>
</html>